#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> M, F;
    string gender;
    double h;
    while (n--) {
        cin >> gender >> h;
        if (gender == "male")M.emplace_back(h);
        if (gender == "female")F.emplace_back(h);
    }
    sort(M.begin(), M.end(), less<double>());
    sort(F.begin(), F.end(), greater<double>());
    for (auto &e : M)cout << fixed << setprecision(2) << e << " ";
    for (auto &e : F)cout << fixed << setprecision(2) << e << " ";
    cout << endl;
    return 0;
}